package com.stone.framework.basic.dict.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Table;

import com.stone.framework.core.entity.CommonEntity;
import com.stone.framework.core.util.Strings;

@Entity
@Table(name = "ST_DICT_MEMBER")
public class DictMember extends CommonEntity {

    private static final long serialVersionUID = -5813698335362382326L;

    /**
     * ST_DICT_CATEGORY表CODE
     */
    @Column(name = "DICT_CATEGORY_CODE")
    private String dictCategoryCode;

    /**
     * 代码标识
     */
    @Column(name = "CODE")
    private String code;

    /**
     * 名称
     */
    @Column(name = "NAME")
    private String name;

    /**
     * 描述
     */
    @Column(name = "DESC_")
    private String desc;

    /**
     * 显示顺序
     */
    @Column(name = "ORDER_")
    private Integer order;

    /**
     * 状态（禁用/隐藏/可用）
     */
    @Enumerated(EnumType.STRING)
    @Column(name = "STATE")
    private State state;

    private static enum State {
        DISABLED, HIDDEN, ENABLED;
    }

    public boolean disabled() {
        return State.DISABLED.equals(this.state);
    }

    public Integer getOrder() {
        return order;
    }

    public void setOrder(Integer order) {
        this.order = order;
    }

    public String getDictCategoryCode() {
        return dictCategoryCode;
    }

    public void setDictCategoryCode(String dictCategoryCode) {
        this.dictCategoryCode = dictCategoryCode;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getState() {
        return state == null ? null : state.name();
    }

    public void setState(String state) {
        this.state = Strings.isEmpty(state) ? null : State.valueOf(state);
    }

    @Override
    public String toString() {
        return "DictMember [dictCategoryCode=" + dictCategoryCode + ", code=" + code + ", name=" + name + ", desc="
            + desc + ", order=" + order + ", state=" + state + ", " + super.toString() + "]";
    }

}
